﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using CCWin;


namespace weiqijiance
{
    public partial class 加载减速法自检 : CCSkinMain
    {
        public 加载减速法自检()
        {
            InitializeComponent();
        }
        public mainform m_mainform;
        string[] sname1 = new string[]{"实际滑行时间",
"计算滑行时间",
"相对误差",
"判定结果",
"实际滑行时间",
"计算滑行时间",
"相对误差",
"判定结果",
"名义速度为24km/h的寄生功率",
"名义速度为32km/h的寄生功率",
"名义速度为40km/h的寄生功率",
"名义速度为48km/h的寄生功率",
"名义速度为56km/h的寄生功率",
"名义速度为64km/h的寄生功率",
"名义速度为72km/h的寄生功率",
"名义速度为80km/h的寄生功率",
"名义速度为88km/h的寄生功率",
"底盘测功机压力计判定"
        };

        string[] sname2 = new string[]{"不透光烟度计零点校准",
"不透光烟度计零点校准误差率",
"不透光烟度计零点校准判定",
            "不透光烟度计30%量程检查",
"不透光烟度计30%量程检查误差率",
"不透光烟度计30%量程检查判定",
"不透光烟度计50%量程检查",
"不透光烟度计50%量程检查误差率",
"不透光烟度计50%量程检查判定",
"不透光烟度计70%量程检查",
"不透光烟度计70%量程检查误差率",
"不透光烟度计70%量程检查判定",
"不透光烟度计90%量程检查",
"不透光烟度计90%量程检查误差率",
"不透光烟度计90%量程检查判定",
"不透光烟度计99.9%量程检查",
"不透光烟度计99.9%量程检查误差率",
"不透光烟度计99.9%量程检查判定"
        };
        string[] sname3 = new string[]{
"1000发动机转速传感器校准",
"1000发动机转速传感器校准误差率",
"1000发动机转速传感器校准判定",
"1500发动机转速传感器校准",
"1500发动机转速传感器校准误差率",
"1500发动机转速传感器校准判定",
"2000发动机转速传感器校准",
"2000发动机转速传感器校准误差率",
"2000发动机转速传感器校准判定",
"3000发动机转速传感器校准",
"3000发动机转速传感器校准误差率",
"3000发动机转速传感器校准判定",
"4000发动机转速传感器校准",
"4000发动机转速传感器校准误差率",
"4000发动机转速传感器校准判定",
"总自检判定"
        };
        string[] smc1 = new string[]{"ACDT40","CCDT40","CDT40_Error","CDT40_Judge","ACDT56","CCDT56","CDT56_Error","CDT56_Judge",
"PLHP24","PLHP32","PLHP40","PLHP48","PLHP56","PLHP64","PLHP72","PLHP80","PLHP88","PressureGage_Judge"};

        string[] smc2 = new string[]{
            "N0" ,
"N0_Error"       ,
"N0_Judge"       ,
"N30",
"N30_Error",
"N30_Judge",
"N50",
"N50_Error",
"N50_Judge",
"N70",
"N70_Error",
"N70_Judge"  ,
    "N90"    ,
"N90_Error"  ,
"N90_Judge"  ,
"N100"       ,
"N100_Error" ,
"N100_Judge" 
};

        string[] smc3 = new string[]{
"N1000",
"N1000_Error",
"N1000_Judge",
"N1500",
"N1500_Error",
"N1500_Judge",
"N2000",
"N2000_Error",
"N2000_Judge",
"N3000",
"N3000_Error",
"N3000_Judge",
"N4000",
"N4000_Error",
"N4000_Judge",
"Judge"};

        private void 加载减速法自检_Load(object sender, EventArgs e)
        {
            iniclass objini = new iniclass();
            string path = "";
            path = System.Windows.Forms.Application.StartupPath + "\\检测自检\\加载减速设备自检信息.ini";
            string path1 = string.Format(@"{0}", path);
            objini.Ini(path1);
            //objzj.StationCode = m_mainform.stationCode;
            //objzj.SceneCode = m_mainform.lineCode;
            for (int i = 0; i < smc1.Length; i++)
            {
                int index = this.dataGridView1.Rows.Add();
                this.dataGridView1.Rows[index].Cells[0].Value = sname1[i];
                this.dataGridView1.Rows[index].Cells[1].Value = objini.ReadValue("记录",smc1[i]).Trim();
            }
            for (int i = 0; i < smc2.Length; i++)
            {
                int index = this.dataGridView3.Rows.Add();
                this.dataGridView3.Rows[index].Cells[0].Value = sname2[i];
                this.dataGridView3.Rows[index].Cells[1].Value = objini.ReadValue("记录", smc2[i]).Trim();
            }
            for (int i = 0; i < smc3.Length; i++)
            {
                int index = this.dataGridView2.Rows.Add();
                this.dataGridView2.Rows[index].Cells[0].Value = sname3[i];
                this.dataGridView2.Rows[index].Cells[1].Value = objini.ReadValue("记录", smc3[i]).Trim();
            }
            //MessageBox.Show(m_mainform.objbass.jianceqianzj("", objzj));
        }

        private void button1_Click(object sender, EventArgs e)
        {

            writeini();
            iniclass objini = new iniclass();
            string path = "";
            path = System.Windows.Forms.Application.StartupPath + "\\检测自检\\加载减速设备自检信息.ini";
            string path1 = string.Format(@"{0}", path);
            objini.Ini(path1);
            model.尾气自检.检测前自检.zijianlug objzj = new model.尾气自检.检测前自检.zijianlug();
            objzj.bzjbz = true;
            objzj.bzjbz = true;
            objzj.StationCode = m_mainform.stationCode;
            objzj.SceneCode = m_mainform.lineCode;
            objzj.ACDT40 = objini.ReadValue("记录", "ACDT40").Trim();
            objzj.CCDT40 = objini.ReadValue("记录", "CCDT40").Trim();
            objzj.CDT40_Error = objini.ReadValue("记录", "CDT40_Error").Trim();
            objzj.CDT40_Judge = objini.ReadValue("记录", "CDT40_Judge").Trim();
            objzj.ACDT56 = objini.ReadValue("记录", "ACDT56").Trim();
            objzj.CCDT56 = objini.ReadValue("记录", "CCDT56").Trim();
            objzj.CDT56_Error = objini.ReadValue("记录", "CDT56_Error").Trim();
            objzj.CDT56_Judge = objini.ReadValue("记录", "CDT56_Judge").Trim();
            objzj.PLHP24 = objini.ReadValue("记录", "PLHP24").Trim();
            objzj.PLHP32 = objini.ReadValue("记录", "PLHP32").Trim();
            objzj.PLHP40 = objini.ReadValue("记录", "PLHP40").Trim();
            objzj.PLHP48 = objini.ReadValue("记录", "PLHP48").Trim();
            objzj.PLHP56 = objini.ReadValue("记录", "PLHP56").Trim();
            objzj.PLHP64 = objini.ReadValue("记录", "PLHP64").Trim();
            objzj.PLHP72 = objini.ReadValue("记录", "PLHP72").Trim();
            objzj.PLHP80 = objini.ReadValue("记录", "PLHP80").Trim();
            objzj.PLHP88 = objini.ReadValue("记录", "PLHP88").Trim();
            objzj.PressureGage_Judge = objini.ReadValue("记录", "PressureGage_Judge").Trim();
            objzj.N30 = objini.ReadValue("记录", "N30").Trim();
            objzj.N30_Error = objini.ReadValue("记录", "N30_Error").Trim();
            objzj.N30_Judge = objini.ReadValue("记录", "N30_Judge").Trim();
            objzj.N50 = objini.ReadValue("记录", "N50").Trim();
            objzj.N50_Error = objini.ReadValue("记录", "N50_Error").Trim();
            objzj.N50_Judge = objini.ReadValue("记录", "N50_Judge").Trim();
            objzj.N70 = objini.ReadValue("记录", "N70").Trim();
            objzj.N70_Error = objini.ReadValue("记录", "N70_Error").Trim();
            objzj.N70_Judge = objini.ReadValue("记录", "N70_Judge").Trim();
            objzj.N1000 = objini.ReadValue("记录", "N1000").Trim();
            objzj.N1000_Error = objini.ReadValue("记录", "N1000_Error").Trim();
            objzj.N1000_Judge = objini.ReadValue("记录", "N1000_Judge").Trim();
            objzj.N2000 = objini.ReadValue("记录", "N2000").Trim();
            objzj.N2000_Error = objini.ReadValue("记录", "N2000_Error").Trim();
            objzj.N2000_Judge = objini.ReadValue("记录", "N2000_Judge").Trim();
            objzj.N3000 = objini.ReadValue("记录", "N3000").Trim();
            objzj.N3000_Error = objini.ReadValue("记录", "N3000_Error").Trim();
            objzj.N3000_Judge = objini.ReadValue("记录", "N3000_Judge").Trim();
            objzj.N4000 = objini.ReadValue("记录", "N4000").Trim();
            objzj.N4000_Error = objini.ReadValue("记录", "N4000_Error").Trim();
            objzj.N4000_Judge = objini.ReadValue("记录", "N4000_Judge").Trim();
            objzj.Judge = objini.ReadValue("记录", "Judge").Trim();
            //objzj.CheckTimeStart = objini.ReadValue("记录", "CheckTimeStart").Trim();
            //objzj.CheckTimeEnd = objini.ReadValue("记录", "CheckTimeEnd").Trim();
            objzj.CheckTimeStart = DateTime.Now.ToString("yyyy-MM-dd") + " " + dateTimePicker1.Value.ToString("HH:mm:ss");
            objzj.CheckTimeEnd = DateTime.Now.ToString("yyyy-MM-dd") + " " + dateTimePicker2.Value.ToString("HH:mm:ss");
            MessageBox.Show(m_mainform.objbass.jianceqianzj("", objzj));

        }

        private void button2_Click(object sender, EventArgs e)
        {
 writeini();
            iniclass objini = new iniclass();
            string path = "";
            path = System.Windows.Forms.Application.StartupPath + "\\检测自检\\加载减速设备自检信息.ini";
            string path1 = string.Format(@"{0}", path);
            objini.Ini(path1);
            model.尾气自检.检测前自检.zijianzyjs objzj = new model.尾气自检.检测前自检.zijianzyjs();
            objzj.bzjbz = true;
            objzj.bzjbz = true;
            objzj.StationCode = m_mainform.stationCode;
            objzj.SceneCode = m_mainform.lineCode;
            objzj.N0 = objini.ReadValue("记录", "N0").Trim();
            objzj.N0_Error = objini.ReadValue("记录", "N0_Error").Trim();
            objzj.N0_Judge = objini.ReadValue("记录", "N0_Judge").Trim();
            objzj.N30 = objini.ReadValue("记录", "N30").Trim();
            objzj.N30_Error = objini.ReadValue("记录", "N30_Error").Trim();
            objzj.N30_Judge = objini.ReadValue("记录", "N30_Judge").Trim();
            objzj.N50 = objini.ReadValue("记录", "N50").Trim();
            objzj.N50_Error = objini.ReadValue("记录", "N50_Error").Trim();
            objzj.N50_Judge = objini.ReadValue("记录", "N50_Judge").Trim();
            objzj.N70 = objini.ReadValue("记录", "N70").Trim();
            objzj.N70_Error = objini.ReadValue("记录", "N70_Error").Trim();
            objzj.N70_Judge = objini.ReadValue("记录", "N70_Judge").Trim();
            objzj.N90 = objini.ReadValue("记录", "N90").Trim();
            objzj.N90_Error = objini.ReadValue("记录", "N90_Error").Trim();
            objzj.N90_Judge = objini.ReadValue("记录", "N90_Judge").Trim();
            objzj.N100 = objini.ReadValue("记录", "N100").Trim();
            objzj.N100_Error = objini.ReadValue("记录", "N100_Error").Trim();
            objzj.N100_Judge = objini.ReadValue("记录", "N100_Judge").Trim();
            objzj.N1000 = objini.ReadValue("记录", "N1000").Trim();
            objzj.N1000_Error = objini.ReadValue("记录", "N1000_Error").Trim();
            objzj.N1000_Judge = objini.ReadValue("记录", "N1000_Judge").Trim();
            objzj.N1500 = objini.ReadValue("记录", "N1500").Trim();
            objzj.N1500_Error = objini.ReadValue("记录", "N1500_Error").Trim();
            objzj.N1500_Judge = objini.ReadValue("记录", "N1500_Judge").Trim();
            objzj.N2000 = objini.ReadValue("记录", "N2000").Trim();
            objzj.N2000_Error = objini.ReadValue("记录", "N2000_Error").Trim();
            objzj.N2000_Judge = objini.ReadValue("记录", "N2000_Judge").Trim();
            objzj.Judge = objini.ReadValue("记录", "Judge").Trim();
            //objzj.CheckTimeStart = objini.ReadValue("记录", "CheckTimeStart").Trim();
            //objzj.CheckTimeEnd = objini.ReadValue("记录", "CheckTimeEnd").Trim();
            objzj.CheckTimeStart = DateTime.Now.ToString("yyyy-MM-dd") + " " + dateTimePicker1.Value.ToString("HH:mm:ss");
            objzj.CheckTimeEnd = DateTime.Now.ToString("yyyy-MM-dd") + " " + dateTimePicker2.Value.ToString("HH:mm:ss");

            MessageBox.Show(m_mainform.objbass.jianceqianzj("", objzj));
        }


        public void writeini()
        {
            iniclass objini = new iniclass();
            string path = "";
            path = System.Windows.Forms.Application.StartupPath + "\\检测自检\\加载减速设备自检信息.ini";
            string path1 = string.Format(@"{0}", path);
            objini.Ini(path1);

            for (int i = 0; i < smc1.Length; i++)
            {
                objini.Writue("记录", smc1[i],Convert.ToString( this.dataGridView1.Rows[i].Cells[1].Value));
            }
            for (int i = 0; i < smc2.Length; i++)
            {
                objini.Writue("记录", smc2[i],Convert.ToString( this.dataGridView3.Rows[i].Cells[1].Value));
            }
            for (int i = 0; i < smc3.Length; i++)
            {
                objini.Writue("记录", smc3[i],Convert.ToString( this.dataGridView2.Rows[i].Cells[1].Value));
            }
        }

        private void button3_Click(object sender, EventArgs e)
        {
            //for (int i = 0; i < smc1.Length; i++)
            //{
            //    objini.Writue("记录", smc1[i], this.dataGridView1.Rows[i].Cells[1].Value.ToString());
            //}

            #region 转速
            {

                double[] flc = new double[5];
                flc[0] = ((float)m_mainform.getRandom(0, 80)) + 960;
                flc[1] = ((float)m_mainform.getRandom(0, 80)) + 1460;
                flc[2] = ((float)m_mainform.getRandom(0, 80)) + 1960;
                flc[3] = ((float)m_mainform.getRandom(0, 80)) + 2960;
                flc[4] = ((float)m_mainform.getRandom(0, 80)) + 3960;
                double[] fwc = new double[6];
                fwc[0] = Math.Round(Math.Abs(1000 - flc[0]) / 1000*100, 2);
                fwc[1] = Math.Round(Math.Abs(1500 - flc[1]) / 1500*100, 2); ;
                fwc[2] = Math.Round(Math.Abs(2000 - flc[2]) / 2000*100, 2); ;
                fwc[3] = Math.Round(Math.Abs(3000 - flc[3]) / 3000*100, 2); ;
                fwc[4] = Math.Round(Math.Abs(4000 - flc[4]) / 4000*100, 2); ;

                dataGridView2.Rows[0].Cells[1].Value = flc[0].ToString();
                dataGridView2.Rows[1].Cells[1].Value = fwc[0].ToString();
                dataGridView2.Rows[2].Cells[1].Value = "1";

                dataGridView2.Rows[3].Cells[1].Value = flc[1].ToString();
                dataGridView2.Rows[4].Cells[1].Value = fwc[1].ToString();
                dataGridView2.Rows[5].Cells[1].Value = "1";

                dataGridView2.Rows[6].Cells[1].Value = flc[2].ToString();
                dataGridView2.Rows[7].Cells[1].Value = fwc[2].ToString();
                dataGridView2.Rows[8].Cells[1].Value = "1";

                dataGridView2.Rows[9].Cells[1].Value = flc[3].ToString();
                dataGridView2.Rows[10].Cells[1].Value = fwc[3].ToString();
                dataGridView2.Rows[11].Cells[1].Value = "1";

                dataGridView2.Rows[12].Cells[1].Value = flc[4].ToString();
                dataGridView2.Rows[13].Cells[1].Value = fwc[4].ToString();
                dataGridView2.Rows[14].Cells[1].Value = "1";

                dataGridView2.Rows[15].Cells[1].Value = "1";

            }
            #endregion

        }

        private void button4_Click(object sender, EventArgs e)
        {

            #region 不透光烟度
            {
                double[] flc = new double[6];
                flc[0] = Math.Round(((double)m_mainform.getRandom(0, 4)) * 0.1, 1);
                flc[1] = Math.Round(((double)m_mainform.getRandom(0, 7)) * 0.1f + 29.8, 1);
                flc[2] = Math.Round(((double)m_mainform.getRandom(0, 7)) * 0.1f + 49.8, 1);
                flc[3] = Math.Round(((double)m_mainform.getRandom(0, 7)) * 0.1f + 69.8, 1);
                flc[4] = Math.Round(((double)m_mainform.getRandom(0, 7)) * 0.1f + 90.9, 1);
                flc[5] = Math.Round(((double)m_mainform.getRandom(0, 5)) * 0.1f + 99.4, 1);
                double[] fwc = new double[6];
                fwc[0] = Math.Round(Math.Abs(0 - flc[0]), 2);
                fwc[1] = Math.Round(Math.Abs(30 - flc[1]), 2);
                fwc[2] = Math.Round(Math.Abs(50 - flc[2]), 2);
                fwc[3] = Math.Round(Math.Abs(70 - flc[3]), 2);
                fwc[4] = Math.Round(Math.Abs(90 - flc[4]), 2);
                fwc[5] = Math.Round(Math.Abs(99.9f - flc[5]), 2);
                dataGridView3.Rows[0].Cells[1].Value = flc[0].ToString();
                dataGridView3.Rows[1].Cells[1].Value = fwc[0].ToString();
                dataGridView3.Rows[2].Cells[1].Value = "1";

                dataGridView3.Rows[3].Cells[1].Value = flc[1].ToString();
                dataGridView3.Rows[4].Cells[1].Value = fwc[1].ToString();
                dataGridView3.Rows[5].Cells[1].Value = "1";

                dataGridView3.Rows[6].Cells[1].Value = flc[2].ToString();
                dataGridView3.Rows[7].Cells[1].Value = fwc[2].ToString();
                dataGridView3.Rows[8].Cells[1].Value = "1";

                dataGridView3.Rows[9].Cells[1].Value = flc[3].ToString();
                dataGridView3.Rows[10].Cells[1].Value = fwc[3].ToString();
                dataGridView3.Rows[11].Cells[1].Value = "1";

                dataGridView3.Rows[12].Cells[1].Value = "";// flc[4].ToString();
                dataGridView3.Rows[13].Cells[1].Value = "";//fwc[4].ToString();
                dataGridView3.Rows[14].Cells[1].Value = "";// "1";

                dataGridView3.Rows[15].Cells[1].Value = flc[5].ToString();
                dataGridView3.Rows[16].Cells[1].Value = fwc[5].ToString();
                dataGridView3.Rows[17].Cells[1].Value = "1";

            }
            #endregion
        }
    }
}
